package rmi;

import java.rmi.NotBoundException;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.rmi.server.UnicastRemoteObject;
import vista.*;

public class ProxyGui extends UnicastRemoteObject implements InterfazCliente{

	private GuiAdministracion gui;
	private FachadaAdmin servidor;
	
	public ProxyGui(GuiAdministracion gui) throws RemoteException {
		super();
		
		this.gui = gui;
		
		try {
			Registry registro = LocateRegistry.getRegistry("127.0.0.1", 1099);
			servidor = (rmi.FachadaAdmin)registro.lookup("serveradmin");
			
			//servidor = (rmi.FachadaAdmin)Naming.lookup("//localhost/serveradmin");
		} catch (RemoteException e) {
			System.out.println("ERROR EXCEPCION REMOTA");
			e.printStackTrace();
		} catch (NotBoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		try {
			servidor.registrarAdmin(this);
		} catch (RemoteException e) {
			System.out.println("ERROR AL REGISTRAR ESTA GUI CON EL SERVIDOR");
			e.printStackTrace();
		}

	}
	
	
	private static final long serialVersionUID = 1L;

	@Override
	public void agregarCuenta() throws RemoteException {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void agregarOficina() throws RemoteException {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void agregarUsuario() throws RemoteException {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void loadLog() throws RemoteException {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void quitarOficina() throws RemoteException {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void quitarUsuario() throws RemoteException {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void updateLog() throws RemoteException {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void updateMsg(String mensaje) throws RemoteException {
		gui.updateMsg(mensaje);
		
	}
	

}
